package com.thingcom.delinrobot.main.adddevice;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.thingcom.delinrobot.R;
import com.thingcom.delinrobot.base.BaseBackFragment;
import com.thingcom.delinrobot.main.device.ChangeLanguageBackFragment;
import com.thingcom.delinrobot.view.SimpleToolbar;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * author : YuFeng
 * e-mail : 923462992@qq.com
 * date   : 2019/12/10
 */
public class AboutCompanyFragment extends BaseBackFragment {

    @BindView(R.id.toolbar_main_about_company)
    SimpleToolbar toolbarMainAboutCompany;
    @BindView(R.id.recycler_main_about_company)
    RecyclerView recyclerMainAboutCompany;


    public static AboutCompanyFragment newInstance() {
        Bundle args = new Bundle();
        AboutCompanyFragment fragment = new AboutCompanyFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_back_main_about_company, container, false);
        unbinder = ButterKnife.bind(this, view);
        initToolbar(toolbarMainAboutCompany);
        initView();
        return view;
    }

    private void initView(){
        List<String> list = new ArrayList<>();
        list.add(getString(R.string.Help_and_support));
        list.add(getString(R.string.Language_selection));
//        list.add(getString(R.string.About_the_DE_app_application));

        recyclerMainAboutCompany.setLayoutManager(new LinearLayoutManager(getContext(), RecyclerView.VERTICAL, false));
        AboutCompanyAdapter adapter = new AboutCompanyAdapter(list);
        adapter.bindToRecyclerView(recyclerMainAboutCompany);
        adapter.setOnItemClickListener((adapter1, view, position) -> {
//                start(LoginMailFragment.newInstance());
//                GizWifiSDK.sharedInstance().bindDevice("83c256b7477840d7976c4181f187dbcf", "d782e8917e0c4275a1ad548937e838fb","KxJu4xkPugQAoyoghZm7Yn", "123456", null);

        if (position==0){
                start(HelpAndSupport.newInstance());
            }
        if (position==1){
            start(ChangeLanguageBackFragment.newInstance());
        }
        });
    }
    private class AboutCompanyAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
        AboutCompanyAdapter(@Nullable List<String> data) {
            super(R.layout.about_company_item,data);
        }

        @Override
        protected void convert(BaseViewHolder helper, String item) {
                helper.setText(R.id.tv_about_company_item,item);
        }
    }
}
